//
//  MyUtil.h
//  YiKeDe
//
//  Created by GuiDaYou on 16/1/17.
//  Copyright © 2016年 李世飞. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

@interface LSF_Util : NSObject


#pragma mark ---------控---件-------

/**
 *  创建UILabel
 *
 *  @param rect  CGRectMake
 *  @param viewA 要添加到view
 *  @param color 创建当前view的颜色
 *
 *  @return return value description
 */
+(UILabel*)labelName:(NSString*)text   fontSize:(CGFloat)font  rect:(CGRect)rect View:(UIView*)viewA Alignment:(NSTextAlignment)alignment Color:(UIColor*)color Tag:(NSInteger)tag;

/**
 *  创建UIImageView
 *
 *  @param imageName 图片名
 *  @param rect      rect description
 *  @param viewA     viewA description
 *  @param tag       tag description
 *
 *  @return return value description
 */
+(UIImageView*)addSubviewImage:(NSString*)imageName  rect:(CGRect)rect View:(UIView*)viewA Tag:(NSInteger)tag;

/**
 *  创建UIView
 *
 *  @param rect  CGRectMake
 *  @param viewA 要添加到view
 *  @param color 创建当前view的颜色
 *
 *  @return return value description
 */
+(UIView *)viewWithRect:(CGRect)rect view:(UIView *)viewA backgroundColor:(UIColor *)color;

/**
 *  创建UIButton
 *
 *  @param photo           图片名
 *  @param Hphoto          图片名
 *  @param rect            rect description
 *  @param title           标题
 *  @param sel             action
 *  @param tag             tag description
 *  @param ViewA           ViewA description
 *  @param textcolor       标题颜色
 *  @param size            标题字体大小
 *  @param backgroundColor button背景颜色
 *
 *  @return return value description
 */
+(UIButton*)buttonPhotoAlignment:(NSString*)photo hilPhoto:(NSString*)Hphoto rect:(CGRect)rect  title:(NSString*)title  Tag:(NSInteger)tag View:(UIView*)ViewA textColor:(UIColor*)textcolor Size:(UIFont*)size backgroundColor:(UIColor*)backgroundColor;


/**
 *  创建UITextField
 *
 *  @param rect           rect description
 *  @param tag            tag description
 *  @param color          color description
 *  @param alignment      alignment description
 *  @param textStr        textStr description
 *  @param placeholderStr placeholderStr description
 *  @param viewA          viewA description
 *
 *  @return return value description
 */
+(UITextField*)addTextFieldView:(CGRect)rect Tag:(NSInteger)tag  textColor:(UIColor*)color Alignment:(NSTextAlignment)alignment Text:(NSString*)textStr  placeholderStr:(NSString *)placeholderStr View:(UIView*)viewA font:(CGFloat)font;

/**
 *  自定义搜索框
 *
 *  @param frame           frame description
 *  @param fontSize        fontSize description
 *  @param searchIconStr   searchIconStr description
 *  @param searchIconFrame searchIconFrame description
 *  @param placeholder     placeholder description
 *  @param holderColor     holderColor description
 *  @param delegate        delegate description
 *
 *  @return return value description
 */
+(UITextField *)addCommonSearchTextFieldView:(CGRect)frame fontSize:(CGFloat)fontSize searchIconStr:(NSString *)searchIconStr searchIconFrame:(CGRect)searchIconFrame placeholder:(NSString *)placeholder placeholderColor:(UIColor *)holderColor delegate:(id<UITextFieldDelegate>)delegate;

/**
 *  创建动画
 *
 *  @param view view description
 *  @param rect rect description
 */
+(void)donghuaView:(UIView*)view  Rect:(CGRect)rect;


/**
 *  创建UITableView
 *
 *  @param rect       rect description
 *  @param tag        tag description
 *  @param ViewA      ViewA description
 *  @param delegate   delegate description
 *  @param dataSource dataSource description
 *
 *  @return return value description
 */
+(UITableView *)add_tableview:(CGRect)rect Tag:(NSInteger) tag View:(UIView *)ViewA delegate:(id <UITableViewDelegate>)delegate dataSource:(id <UITableViewDataSource>)dataSource;

/**
 *  创建UIScrollView
 *
 *  @param rect  rect description
 *  @param tag   tag description
 *  @param ViewA ViewA description
 *  @param co    co description
 *
 *  @return return value description
 */
+(UIScrollView *)add_scollview:(CGRect)rect Tag:(NSInteger) tag View:(UIView *)ViewA  co:(CGSize)co;

/**
 *  通过UILable创建线条
 *
 *  @param color color description
 *  @param rect  rect description
 *  @param View  View description
 *
 *  @return return value description
 */
+(UILabel *)setXianTiao:(UIColor *)color rect:(CGRect)rect view:(UIView *)View;

/**
 *  创建左剪头图标
 *
 *  @param view view description
 *
 *  @return return value description
 */
+(UIImageView *)addIndicatorInView:(UIView *)view;



#pragma mark - ---------常用工厂方法----------
/**
 *  16进制转color
 *
 *  @param hexColor hexColor description
 *
 *  @return return value description
 */
+( UIColor *) getColor:( NSString *)hexColor;


/**
 *  动态计算label的高度
 *
 *  @param text     text description
 *  @param fontsize fontsize description
 *  @param width    width description
 *
 *  @return return value description
 */
+ (CGFloat)getLabHeight:(NSString *)text FontSize:(CGFloat)fontsize Width:(NSInteger)width;



/**
 *  动态计算label的宽度
 *
 *  @param text     text description
 *  @param fontsize fontsize description
 *  @param height   height description
 *
 *  @return return value description
 */
+ (CGFloat)getLabWidth:(NSString *)text FontSize:(CGFloat)fontsize Height:(NSInteger)height;


/**
 *  判断对象是否为空
 *
 *  @param obj obj description
 *
 *  @return return value description
 */
+(BOOL)isEmpty:(id)obj;


/**
 *  判断密码是否满足要求
 *
 *  @param _text _text description
 *
 *  @return return value description
 */
+(BOOL)validatePassWord:(NSString  *)_text;

#pragma mark - 关于日期的几个方法
/**
 *  比较2个日期的大小
 *
 *  @param firstDate  firstDate description
 *  @param secondDate secondDate description
 *
 *  @return return value description
 */
+(BOOL)JudgeTwoDate:(NSString*)firstDate secondDate:(NSString*)secondDate;
/**
 *  比较2个时间的大小
 *
 *  @param firstDate  firstDate description
 *  @param secondDate secondDate description
 *
 *  @return return value description
 */
+(BOOL)JudgeTwoTime:(NSString*)firstDate secondDate:(NSString*)secondDate;


/**
 *  获取现在日期
 *
 *  @return return value description
 */
+(NSString*)getNowDate;

/**
 *  获取现在时间
 *
 *  @return return value description
 */
+(NSString*)getNowTime;

//
/**
 *  获取某个日期的前一天或后一天 tag 1:后一天 0:前一天
 *
 *  @param date date description
 *  @param tag  tag description
 *
 *  @return return value description
 */
+(NSString*)getLastOrNextDate:(NSString*)date tag:(int)tag;

/**
 *  获取N分钟之后的时间
 *
 *  @param startDate startDate description
 *  @param N         N description
 *
 *  @return return value description
 */
+(NSString*)getNhoursTime:(NSString*)startDate N:(int)N;



/**
 *  获取某个日期几天之后的日期
 *
 *  @param date  date description
 *  @param index index description
 *
 *  @return return value description
 */
+(NSString*)getNextSomeDay:(NSString*)date index:(int)index;

/**
 *  获取某个日期是星期几
 *
 *  @param date date description
 *
 *  @return return value description
 */
+(NSString*)getWeekFromDate:(NSDate*)date;


/**
 *  获取某个日期是星期几
 *
 *  @param date date description
 *
 *  @return return value description
 */
+(NSString*)getWeekFromDateStr:(NSString*)date;

/**
 *  将NSString转换为NSDate
 *
 *  @param date date description
 *
 *  @return return value description
 */
+ (NSString *)stringFromDate:(NSDate *)date;

/**
 *  将NSDate转换成NSString
 *
 *  @param dateStr dateStr description
 *
 *  @return return value description
 */
+ (NSDate *)dateFromString:(NSString *)dateStr;


#pragma mark - 图片处理

/**
 *  将图片比例压缩成正方形
 *
 *  @param image   image description
 *  @param newSize newSize description
 *
 *  @return return value description
 */
+ (UIImage *)squareImageFromImage:(UIImage *)image scaledToSize:(CGFloat)newSize;


/**
 *  将图片比例压缩成长方形
 *
 *  @param sourceImage sourceImage description
 *  @param size        size description
 *
 *  @return return value description
 */
+(UIImage *) imageCompressForSize:(UIImage *)sourceImage targetSize:(CGSize)size;


#pragma mark - 判断字符串是否是纯数字
/**
 *  判断是否为纯数字
 *
 *  @param numStr numStr description
 *
 *  @return return value description
 */
+(BOOL)isPureNumber:(NSString *)numStr;


/**
 *  判断是否为整形
 *
 *  @param string string description
 *
 *  @return return value description
 */
+ (BOOL)isPureInt:(NSString*)string;


/**
 *  判断是否为浮点形
 *
 *  @param string string description
 *
 *  @return return value description
 */
+ (BOOL)isPureFloat:(NSString*)string;

@end
